const fs=require('fs')//获取
const path=require('path')
const http=require('http')
const url=require('url')

const server=http.createServer((req,res)=>{

    res.setHeader('Content-Type','text/html;charset=utf8')

    if(req.url=='/'||req.url=='/index'){

        fs.readFile(path.join(__dirname,'./index.html'),'utf8')

    }else if(req.url=='./list'){

        let data={status:200,list:[{name:'chs'},{name:'嗨嗨'}]}

        res.write(JSON.stringify(data))

        res.end('我是list请求完后end函数调用')
    }

})

server.listen(2000,()=>{

    console.log('2000端口运行了');

})